The present invention relates to a method for shape detection, by which a specified shape is detected based on image information of an object.
As a method conventionally used for detecting the shape of an object in many cases, there is a template matching method. In the template matching method, a specified partial image is previously cut out from a standard image of the object, and then stored in a memory as a standard template. For each point in the image of the object at detecting time, a partial image located at a relative position to the point as reference is cut out to calculate similarity to the stored standard template and detect a position coinciding with the standard template based on the similarity. The similarity is generally obtained by calculating a sum of absolute values of the difference between points (pixels) respectively corresponding to the standard template and the partial image. Then, a position of the partial image where the similarity becomes minimum is used as a detecting position.
However, it is possible to carry out erroneous detection when the image has some change in brightness by the conventional method. This is described using an image of an object with reference to FIG. 32. It is assumed that a purpose is to detect a position of a circular hole 11 formed in a plate 10. Reference numeral 12 denotes a background portion. First, a standard template is stored. At that time, for simplification, the density of the plate portion is 50 uniformly, the density of the hole portion is 20 uniformly, and each portion surrounded by a dotted line 13 is stored in memory as the standard template. When a similar object is picked up to recognize the position of the circular hole, it is assumed that the density of the plate portion is changed to 100, the density of the hole portion is changed to 70, and the density of background portion is changed to 40 in accordance with the change in brightness with time. The similarity when the standard template completely coincides with a partial image is found by Expression 25 wherein the number of pixels in the hole portion within the template is Nh and the number of the pixels in the plate portion is Nb. EQU Nh.times..vertline.70-20.vertline.+Nb.times..vertline.100-50.vertline.=50.t imes.Nh+50.times.Nb (Expression 25)
Similarity when the partial image is cut out from the background portion is found by Expression 26. EQU Nh.times..vertline.40-20.vertline.+Nb.times..vertline.40-50.vertline.=20.ti mes.Nh+10.times.Nb (Expression 26)
In such a case, the similarities when the partial image is present in the background portion becomes smaller than those when the partial image is not present therein, as shown by the Expressions 25 and 26. Thus, it may be erroneously detected that the object to be detected is present in the background portion.